package com.sscaipiao.android.activity.DaLeTou;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.sscaipiao.android.R;
import com.sscaipiao.android.activity.Base.RedBallDoubleArrayBase1Activity;
import com.sscaipiao.android.common.Constants;

/**
 * Created by Airay.Rong on 14-1-2.
 */
public class DaLeTouActivity extends RedBallDoubleArrayBase1Activity {
	private final static int MAX_BALL_NUM1 = 35;
	private final static int MAX_BALL_NUM2 = 12;
	private final static int MIN_CHOOSE_NUM1 = 5;
	private final static int MIN_CHOOSE_NUM2 = 2;
	private final static Class ACTIVITY_HIS = DaLeTouHistoryActivity.class;
	private final static Class ACTIVITY_PAY = DaLeTouPayActivity.class;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addContainerMain(R.layout.red_ball_double_array_activity);
		setupUI(true, false, true, true, true);
		setTitleText("大乐透");
		setInfo("红球区 至少选择5个红球");
		addRedBalls(MAX_BALL_NUM1);
		addBlueBalls(MAX_BALL_NUM2);
		setRadomBallNum(MIN_CHOOSE_NUM1, MIN_CHOOSE_NUM2);
		LOTT_CODE = Constants.getLottCodeByClass(DaLeTouActivity.class);
		setupHeadBar(LOTT_CODE);
		reCalculatorSum();
		setupLottLostValues();
	}

	@Override
	public void onResume() {
		super.onResume();

	}

	@Override
	public void onClick(View v) {
		super.onClick(v);
		if (R.id.btn_confirm == v.getId()) {
			doConfirm();
		}
		if (R.id.btn_show_history == v.getId()) {
			showLottHistory(ACTIVITY_HIS);
		}
	}

	private boolean checkChooseBallRules() {
		int nRedNum = queryChoseRedBallNum();
		int nBlueNum = queryChoseBlueBallNum();
		if (nRedNum < MIN_CHOOSE_NUM1) {
			String text = "前区号码中请选择" + MIN_CHOOSE_NUM1 + "个或以上红球";
			Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
			return false;
		}
		if (nBlueNum < MIN_CHOOSE_NUM2) {
			String text = "后区号码中请选择" + MIN_CHOOSE_NUM2 + "个或以上蓝球";
			Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
			return false;
		}
		return true ;
	}



	private void doConfirm() {
		if (checkChooseBallRules() == false) {
			return;
		}
		checkAndStartPayActivity(ACTIVITY_PAY);

	}


}